/*
*Author:Jackong
*Date:2012/07/05
*/
#include "StdAfx.h"
#include "conn_info.h"

namespace fly {

	namespace jld{

		namespace server {	
			conn_info::conn_info()
				:proof_index_(0)
				,rtt_(0)
				,delta_time_(0)
				,account_()
			{
			}

			const size_t& conn_info::add_sync_time(const __int64& rtt, const __int64& dt)
			{
				rtt_ += rtt;
				delta_time_ += dt;
				return ++proof_index_;
			}
			bool conn_info::cal_sync_time()
			{
				if (0 == proof_index_)
				{
					LOG_ERR("can't calculate sync time with proof_index == 0");
					return false;
				}
				rtt_ /= proof_index_;
				delta_time_ /= proof_index_;
				proof_index_ = 0;
				return true;
			}
			conn_info::~conn_info()
			{
			}

			const __int64& conn_info::rtt()
			{
				return rtt_;
			}
			const __int64& conn_info::delta_time()
			{
				return delta_time_;
			}
			void conn_info::set_account(const string& account)
			{
				account_ = account;
			}
			const string& conn_info::account()
			{
				return account_;
			}
		}
	}
}